/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hitechbangla.fctu.base.radar;

import com.hitechbangla.fctu.base.aircraft.AircraftType;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Irteza
 */
public class RadarType implements Serializable{

    private String typeName;
    private double radarRange;
    private int RPM;
    private double aperture;
    private float blipScanRatio;

    /* Constructor for radarType class */
    public RadarType(String typeName, float radarRange, int RPM, float blipScanRatio) {
	this.typeName = typeName;
	this.radarRange = radarRange;
	this.RPM = RPM;
        this.blipScanRatio=blipScanRatio;
	aperture = 2.0;
	//this.location = location;
    }

    public String getRadarType() {
	return typeName;
    }

    public double getRadarRange() {
	return radarRange;
    }

    public int getRPM() {
	return RPM;
    }

    public double getAperture() {
	return aperture;
    }
   public float getBlipScanRatio()
   {
       return blipScanRatio;
   }
    
    /*
     * Return all saved radar type from the radarType.object
     */
    public static List<RadarType> getAllRadarType() {
	try {
	    FileInputStream fileInputStream = new FileInputStream("src/resources/radarType.object");
	    ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);

	    List<RadarType> listRadarType = (List<RadarType>) objectInputStream.readObject();
	    objectInputStream.close();
	    return listRadarType;
	} catch (Exception ex) {
            return new ArrayList<RadarType>();
	}
    }
   public static void updateRadar(List<RadarType> listRadarType)
    {
	try
	{
	    FileOutputStream fileOutputStream = new FileOutputStream("src/resources/radarType.object");
	    ObjectOutputStream  objectOutputStream = new ObjectOutputStream(fileOutputStream);

	    objectOutputStream.writeObject(listRadarType);
	    objectOutputStream.close();
	}
	catch(Exception ex)
	{
	    
	}
    } 
}
